package com.zaofan.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zaofan.bean.OrderDetail;
import com.zaofan.dao.OrderDetailDao;

public class OrderDetailService {

	private OrderDetailDao orderDetailDao = new OrderDetailDao();

	public void delete(OrderDetail orderDetail) {
		orderDetailDao.del(orderDetail);
	}

	public void add(OrderDetail orderDetail) {
		orderDetailDao.add(orderDetail);
	}

	public void update(OrderDetail orderDetail) {
		orderDetailDao.update(orderDetail);
	}

	public List<OrderDetail> findAll(Map<String, Object> params) {
		List<OrderDetail> data = orderDetailDao.findAll(params);
		if (data == null) {
			data = new ArrayList<>();
		}
		return data;
	}

	public Long count(Map<String, Object> params) {
		return orderDetailDao.count(params);
	}

	public OrderDetail findById(Integer id) {
		Map<String, Object> params = new HashMap<>();
		params.put("id", id);
		return orderDetailDao.findOne(params);
	}

	public List<OrderDetail> findByOrderId(int orderId) {
		Map<String, Object> params = new HashMap<>();
		params.put("orderId", orderId);
		return orderDetailDao.findAll(params);
	}

	public List<OrderDetail> findByParentOrderId(int parentOrderId) {
		Map<String, Object> params = new HashMap<>();
		params.put("parentOrderId", parentOrderId);
		return orderDetailDao.findAll(params);
	}

}
